#include <fcntl.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

static int fd;

/*
 * ./dht11_test /dev/dht11
 *
 */
int main(int argc, char **argv)
{

	int ret;
	char buf[1];

		/* 1. 判断参数 */
		if (argc != 2)
	{
		printf("Usage: %s <dev>\n", argv[0]);
		return -1;
	}

	/* 2. 打开文件 */
	fd = open(argv[1], O_RDWR);
	if (fd == -1)
	{
		printf("can not open file %s\n", argv[1]);
		return -1;
	}

	while (1)
	{
		ret = read(fd, buf, 2);
		printf("ret:%d\n", ret);
		if (ret == 2)
			printf("get irda, device: 0x%x, data: 0x%x\n",buf[0], buf[1]);
		sleep(5);
	}
	close(fd);
	return 0;
}
